package cluster;

import redis.clients.jedis.HostAndPort;
import redis.clients.jedis.JedisCluster;
import redis.clients.jedis.JedisPoolConfig;

import java.util.HashSet;
import java.util.Set;

public class RedisCluster {
    public static void main(String[] args) {
        JedisPoolConfig config = new JedisPoolConfig();
        Set<HostAndPort> jedisCLusterNode = new HashSet<HostAndPort>();
        jedisCLusterNode.add(new HostAndPort("10.211.55.10", 7001));
        jedisCLusterNode.add(new HostAndPort("10.211.55.10", 7002));
        jedisCLusterNode.add(new HostAndPort("10.211.55.10", 7003));
        jedisCLusterNode.add(new HostAndPort("10.211.55.10", 7004));
        jedisCLusterNode.add(new HostAndPort("10.211.55.10", 7005));
        jedisCLusterNode.add(new HostAndPort("10.211.55.10", 7006));
        jedisCLusterNode.add(new HostAndPort("10.211.55.10", 7007));
        jedisCLusterNode.add(new HostAndPort("10.211.55.10", 7008));

        JedisCluster jcd = new JedisCluster(jedisCLusterNode, config);
        jcd.set("name:001", "zhangfei");
        String value = jcd.get("name:001");
        System.out.println("result is " + value);
    }
}
